package com.beans;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;

/**
 * \* Created with IntelliJ IDEA.
 * \* User: Administrator
 * \* Date: 2022/7/8
 * \* Time: 15:23
 * \* To change this template use File | Settings | File Templates.
 * \* Description:
 * \
 */

/**
 * 使用构造方法实现bean注入
 */
@Controller
public class UserController3 {

    private UserService userService;

    @Autowired
    public UserController3(UserService userService){
        //userService = new UserService();//传统写法
        this.userService = userService;
    }

    public void  sayHi(){
        userService.sayHi();
    }
}
